from django.shortcuts import render
from . import models
from rest_framework.generics import ListAPIView
from . import models
from . import serializers
from rest_framework.pagination import LimitOffsetPagination
from django.conf import settings



# Create your views here.


class CustomPage(LimitOffsetPagination):
    # 默认每一页的查询的数据量类似于page_size
    default_limit = 2


class BannerAPIView(ListAPIView):
    queryset = models.Banner.objects.filter(is_deleted=False, is_show=True)
    serializer_class = serializers.BannerModelSerializer
    pagination_class = CustomPage


class HeaderNavAPIView(ListAPIView):
    queryset = models.Nav.objects.filter(is_deleted=False, is_show=True, position=1).order_by("-orders")
    serializer_class = serializers.NavModelSerializer


